package btanalyzer.db.model;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;
import javax.validation.constraints.NotNull;

@Entity
@Table(name="CATEGORY", uniqueConstraints={
		@UniqueConstraint(columnNames="NAME", name="CATEGORY__NAME_UK")})
public class Category {
	
	@Id
	@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "seq")
    @SequenceGenerator(name = "seq", sequenceName = "CATEGORY_SEQ")
    @Column(name="CATEGORY_ID")
	private Long id;
	public void setId(Long id) {
		this.id = id;
	}
	public Long getId() {
		return id;
	}
	
	@NotNull
	@Column(name="NAME")
	private String name;
	public void setName(String name) {
		this.name = name;
	}
	public String getName() {
		return name;
	}
	
	@NotNull
	@OneToMany(mappedBy="category")
	private Set<DiggedSite> diggedSites = new HashSet<DiggedSite>();
	public void setDiggedSites(Set<DiggedSite> diggedSites) {
		this.diggedSites = diggedSites;
	}
	public Set<DiggedSite> getDiggedSites() {
		return diggedSites;
	}
	
}
